package com.study.juc;

import org.junit.Test;

import java.util.concurrent.TimeUnit;

public class ThreadTest {


    public static void main(String[] args) throws InterruptedException {

        test1();
        
    }

    public static void test1() throws InterruptedException {


        
        
        Runnable a = new Runnable() {
            @Override
            public void run() {
                Thread.currentThread().interrupt();
                System.out.println("自己打断");
                    try {
                        System.out.println(1);
                        TimeUnit.SECONDS.sleep(1);
                        System.out.println(2);
                    } catch (InterruptedException e) {
                        System.out.println("被打断了"+Thread.currentThread().isInterrupted());
                    }

            }
        };
        
        Thread thread = new Thread(a);
        thread.start();

        TimeUnit.SECONDS.sleep(2);

        
    }
}
